#include "stdafx.h"
#include "FileStruct.h"
void loadDOM(std::list<struct FileStruct> &li, string xmlString, TiXmlEncoding encode)
{
	TiXmlDocument doc;
	doc.SetCondenseWhiteSpace(false);
	doc.Parse(xmlString.c_str(),0,TIXML_ENCODING_LEGACY);
	struct FileStruct temp;

	TiXmlElement *pEle = NULL;
	TiXmlElement *pRootEle  = doc.RootElement();
	for (pEle = pRootEle->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement())    
	{    
		TiXmlElement *fileAttribute = pEle->FirstChildElement();
		for(; fileAttribute; fileAttribute = fileAttribute->NextSiblingElement())
		{
			string t = fileAttribute->Value();
			if ( "fileID" == t)
				temp.fileID = fileAttribute->GetText();
			else if ("fileName" == t)
				temp.fileName = fileAttribute->GetText();
			else if("parentID" == t)
				temp.parentID = fileAttribute->GetText();
			else if("fileType" == t)
				temp.fileType = fileAttribute->GetText();
			else if("SHA" == t)
				temp.SHA = fileAttribute->GetText();

		}

		li.push_back(temp);
	}

}